import http from '@/api'

const permissionUrl = `${import.meta.env.VITE_APP_API_ADMIN_URL}/permission`

const importUrl = permissionUrl + '/import'

// 查询权限列表
const getPermissionList = (params: any) => {
  return http.get(`${permissionUrl}`, params)
}

// 查询context列表
const getContextList = () => {
  return http.get(`${permissionUrl}/contextPath`)
}

// 保存权限
const savePermission = (params: any) => {
  return http.post(`${permissionUrl}`, params)
}

// 更新权限
const updatePermission = (params: any) => {
  return http.put(`${permissionUrl}`, params)
}

// 同步权限
const syncPermission = (params: any) => {
  return http.post(`${permissionUrl}/sync`, params)
}

// 删除权限
const delPermission = (params: any) => {
  return http.delete(`${permissionUrl}`, params)
}

// 导入权限
const importPermission = (params: any) => {
  return http.post(`${permissionUrl}/import`, params)
}

const PermissionService = {
  importUrl: importUrl,
  getPermissionList: getPermissionList,
  getContextList: getContextList,
  savePermission: savePermission,
  updatePermission: updatePermission,
  syncPermission: syncPermission,
  delPermission: delPermission,
  importPermission: importPermission
}

export default PermissionService
